package com.jzg.jcptadmin.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jzg.jcptadmin.R;

/**
 * Created by jzg on 2016/3/30.
 */
public class TaskInfoView extends RelativeLayout{

    private TextView tv1;
    private EditText editText;
    private String type;
    public TaskInfoView(Context context,String name ) {
        super(context);
        initView(context);
        setText(name,"请输入"+name);
    }


    public void setInputType(String type){
        this.type = type;
    }


    public TaskInfoView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public TaskInfoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }
    private void initView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.task_info_view, null);
        tv1 = (TextView) view.findViewById(R.id.tv_vin);
        editText = (EditText) view.findViewById(R.id.tv_mvin);
        this.addView(view);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        this.setGravity(Gravity.CENTER);
        this.setLayoutParams(params);
    }

    /**
     *
     * @param name
     * @param hint
     */
    public void setText(String name,String hint){
        tv1.setText(name);
        editText.setHint(hint);
    }

    public String getText(){
        return editText.getText().toString();
    }
}
